//****************************
//** CSpriteLow
//**
//** Low-Level sprite class
//**
//****************************
#pragma once

#include "stdafx.h"
#include "CImageHigh.h"

class CSpriteLow : public CImageHigh
{
private:
    float m_X_Loc, m_Y_Loc;
    float m_X_Dir, m_Y_Dir;
    float m_X_Spd, m_Y_Spd;

    HBITMAP m_hUnder;
	HBITMAP m_hUnderOld;
    HDC m_hdcUnder;
	BOOL m_bAutoDraw;
    BOOL m_bUnderSaved;
    BOOL m_bAlive;
    LPRECT m_DestRect;
    RECT *m_Rect1;
    RECT *m_Rect2;
	int m_iShrinkX, m_iShrinkY;
	int m_iZOrder;
	BOOL m_bTileCollisionsOn;

	BOOL m_bShouldErase;	//whether this sprite is erased on flipbackbuffer

    void Init();

public:
	int m_iStoreVelocity;
	int m_iStoreVelocityIncrement;
	int m_iStoreVelocityCurrentIncrement;
	int m_iStoreDirection;
    CSpriteLow();
    CSpriteLow(HDC hdc);
    virtual ~CSpriteLow();
    BOOL SaveUnder(HDC hdc);
	BOOL SaveUnder(HDC hdc, int iXOffset, int iYOffset);
    BOOL RestoreUnder(HDC hdc);
    virtual BOOL TransBlit(COLORREF clrTrans);
    virtual BOOL BitBlit();
    virtual BOOL BitBlit(HDC hdc);
    virtual BOOL StretchBlit(int dx, int dy);
    virtual int ImageWidth() { return CImageHigh::ImageWidth(); };
    virtual int ImageHeight() { return CImageHigh::ImageHeight(); };
    virtual BOOL Intersected(CSpriteLow *Sprite, POINT &pt);
    virtual BOOL Intersected(CSpriteLow *Sprite, RECT &rt);
    virtual BOOL IntersectedRect(RECT *rect1);

    BOOL IsAlive() { return m_bAlive; };
    void SetAlive(BOOL bNew) { m_bAlive = bNew; };
    float GetX() { return m_X_Loc; };
    void SetX(float vNew) { m_X_Loc = vNew; };
    void IncX(float vNew) { m_X_Loc += vNew; };
    float GetY() { return m_Y_Loc; };
    void SetY(float vNew) { m_Y_Loc = vNew; };
    void IncY(float vNew) { m_Y_Loc += vNew; };
    float GetXDir() { return m_X_Dir; };
    void SetXDir(float vNew) { m_X_Dir = vNew; };
    float GetYDir() { return m_Y_Dir; };
    void SetYDir(float vNew) { m_Y_Dir = vNew; };
    float GetXSpeed() { return m_X_Spd; };
    void SetXSpeed(float vNew) { m_X_Spd = vNew; };
    float GetYSpeed() { return m_Y_Spd; };
    void SetYSpeed(float vNew) { m_Y_Spd = vNew; };
	
	void SetDirection(int vNew) { m_iStoreDirection = vNew; }
	int GetDirection() { return m_iStoreDirection; }

	void SetVelocity(int vNew) { m_iStoreVelocity = vNew; }
	int GetVelocity() { return m_iStoreVelocity; }

	// velocity increment - how often to update position with velocity
	void SetVelocityIncrement(int vNew) { m_iStoreVelocityIncrement = vNew; }
	int GetVelocityIncrement() { return m_iStoreVelocityIncrement; }
	
	void SetAutoDraw(BOOL vNew) { m_bAutoDraw = vNew; }
	BOOL GetAutoDraw() { return m_bAutoDraw; }

	void SetShrinkX(int vNew) { m_iShrinkX = vNew; }
	int GetShrinkX() { return m_iShrinkX; }
	void SetShrinkY(int vNew) { m_iShrinkY = vNew; }
	int GetShrinkY() { return m_iShrinkY; }

	void SetZOrder(int vNew) { m_iZOrder = vNew; }
	int GetZOrder() { return m_iZOrder; }

	void SetTileCollisionsOn(BOOL vNew) { m_bTileCollisionsOn = vNew; }
	BOOL GetTileCollisionsOn() { return m_bTileCollisionsOn; }

	void SetShouldErase(BOOL vNew) { m_bShouldErase = vNew; }
	BOOL GetShouldErase() { return m_bShouldErase; }

	void DeleteUnder();

};



